<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use DB;


class ExchangeCode extends Authenticatable
{
    use Notifiable;
	protected $table = 'exchange_code';

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
         'remember_token',
    ];

    // 获取列表
	public static function getExchangeCodeList(){
		$exchangeCodes = DB::table('exchange_code')
			->leftjoin('bank_show', 'bank_show.id', '=', 'exchange_code.bank_show_id')
			->where('is_del',1)
			->select('exchange_code.*','bank_show.shopName')
			->get()
			->toArray();
		if(!$exchangeCodes){
			return array();
		}
		return $exchangeCodes;
	}

	// 根据id或者名称
	public static function getNameById($id){
		$exchange_code = '';
		$exchange_code = ExchangeCode::where('id',$id)->pluck('exchange_code');
		if($exchange_code){
			$exchange_code = $exchange_code[0];
		}
		return $exchange_code;
	}

	// 获取激活用户信息
	public static function getExchangeCodeUser($eid){
		$users = DB::table('exchange_code')
			->leftjoin('user_account', 'exchange_code.open_id', '=', 'user_account.open_id')
			->where('exchange_code.id',$eid)
			->select('user_account.*')
			->get()
			->toArray();
		if(!$users){
			return array();
		}
		return $users;
	}




}
